import org.apache.ibatis.session.SqlSession;
import org.example.Utils.MyBatisUtils;
import org.example.mapper.WorkerMapper;
import org.example.pojo.Worker;
import org.junit.Test;

public class WorkerTest {
    @Test
    public void findWorkerByIdTest() {
        SqlSession session = MyBatisUtils.getSession();
        WorkerMapper mapper = session.getMapper(WorkerMapper.class);

        Worker worker = mapper.selectworker(1);
        System.out.println(worker);
        session.close();
    }
    @Test
    public void findWorkerTest(){
        SqlSession session = MyBatisUtils.getSession();
        WorkerMapper mapper = session.getMapper(WorkerMapper.class);

        Worker worker = new Worker();
        worker.setName("赵七");
        worker.setAge(36);
        worker.setSex("女");
        worker.setWorkerId(1004);
        int result = mapper.insertWorker(worker);
        if (result >0){
            System.out.println("插入成功");
        }else{
            System.out.println("插入失败");
        }
        System.out.println(worker);
        session.commit();
        session.close();
    }
}
